#include "textures.h"

//#include <windows.h>

TextureManager::TextureManager(void)
{
	memset(textures, 0x00, sizeof(GLuint)*TEXTURES_TOTAL);
	names[0] = "./data/gfx/particle.tga";
	names[1] = "./data/gfx/console_font.tga";
	names[2] = "./data/gfx/grenade_launcher_weapon.tga";
}

TextureManager::~TextureManager(void)
{
	
}

void TextureManager::loadTextures(void)
{	
	glGenTextures(2, &textures[0]);
	

	for (int i = 0; i < TEXTURES_TOTAL; ++i)
	{	
		glBindTexture(GL_TEXTURE_2D, textures[i]);
		if (glfwLoadTexture2D(names[i], GLFW_BUILD_MIPMAPS_BIT) != GL_TRUE)
		{
			printf("Error loading textures: %s.\r\n",names[i]);
			exit(1);
		}
	}
	
	//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
	glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
}

GLuint TextureManager::getTexture(int i)
{
	return textures[i];
}
